package com.summer.test;

import java.util.Arrays;

public class testLC34 {
    public static int[] searchRange(int[] nums, int target) {
        if (nums.length==0) return new int[]{-1,-1};
        int l = -1;
        int r = -1;
        int left = 0;
        int right = nums.length-1;
        boolean lt= false;
        boolean rt = false;
        while(left <= right&&(!lt||!rt)){
            if(nums[left] != target && !lt) left ++;
            else {
                l = left;
                lt = true;
            }
            if(nums[right] != target && !rt) right --;
            else {
                r = right;
                rt = true;
            }
        }
        return new int[]{l,r};
    }

    public static void main(String[] args) {
        int[] arr = new int[]{5,7,7,8,10};
        System.out.println(Arrays.toString(searchRange(arr,8)));
    }
}
